package com.zyasdk.service;

import android.content.Context;
import android.util.Base64;
import android.util.Log;

import com.zyasdk.model.Activates;
import com.zyasdk.util.AppInfoUtil;
import com.zyasdk.util.JSONHelper;
import com.zyasdk.util.ScreenUtils;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.util.ArrayList;
import java.util.List;

/**
 * Activate Statistics
 * 
 */
public class ActivatesService extends BaseService {

	public ActivatesService(Context context) {
		super(context);
	}

	public void AddActivates(final int packid, final String pBindKey) {
		Activates ac = new Activates();
		ac.setBrand(android.os.Build.BRAND);
		ac.setHeight(ScreenUtils.getScreenHeight(context) + "");
		ac.setImei(AppInfoUtil.getIMEI(context));
		ac.setImsi(AppInfoUtil.getIMSI(context));
		ac.setMac(AppInfoUtil.getMac(context));
		ac.setMemory(AppInfoUtil.getTotalMemorySize(context) + "");
		ac.setModel(android.os.Build.MODEL);
		ac.setPbindkey(pBindKey);
		ac.setPhone(AppInfoUtil.getPhoneNumber(context));
		ac.setSsdk(android.os.Build.VERSION.SDK_INT + "");
		ac.setSversion(android.os.Build.VERSION.RELEASE);
		ac.setVcode(AppInfoUtil.getVersionCode(context));
		ac.setWidth(ScreenUtils.getScreenWidth(context) + "");
		ac.setPackid(packid + "");
		ac.setInstallDir(ScreenUtils.isInstallDir(context));
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("activate", new String(Base64.encode(
				JSONHelper.toJSON(ac).getBytes(), Base64.DEFAULT))));
		Log.i("result", "onCreate+AddActivates ");
		ServiceTask.addTask(GetAPIUrl("AddActivate"), params);
	}
}
